package com.chendx.article.config;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import groovy.util.logging.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by chendx on 2022/3/18.
 */
@Configuration
@Log4j2
public class XxlJobConfig {
    @Value("${xxljob.admin.addresses}")
    private String adminAddresses;
    @Value("${xxljob.executor.appname}")
    private String appname;
    @Value("${xxljob.executor.port}")
    private int port;

    @Bean
    public XxlJobSpringExecutor xxlJobExecutor(){
        XxlJobSpringExecutor  xxlJobExecutor = new XxlJobSpringExecutor ();
        xxlJobExecutor.setAdminAddresses(adminAddresses);
        xxlJobExecutor.setAppName(appname);
        xxlJobExecutor.setPort(port);
        xxlJobExecutor.setLogRetentionDays(30);
        return xxlJobExecutor ;
    }

}
